package com.swak.vertx.protocol.http.adapter;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;

/**
 * 定义基本的适配器
 * 
 * @author lifeng
 */
public abstract class AbstractAdapter implements Adapter {

	Adapter next;

	@Override
	public Adapter chain(Adapter next) {
		this.next = next;
		return next;
	}

	/**
	 * 继续处理下一个
	 * 
	 * @param ctx
	 */
	protected CompletionStage<Context> next(Context context) {
		if (next != null) {
			return next.handle(context);
		}
		return CompletableFuture.completedFuture(context);
	}
}